<?php
namespace Home\Controller;
use Home\Controller\BaseController;
class ListController extends BaseController {
	public function _initialize(){
	}
    public function index(){
	 $meg=I('get.');
	  $this->assign('classmeg',$meg);
	  parent::index("goods","yjl_classid",$meg['id']);
    }
	public function news(){
		parent::index("news");
      }
	public function search(){
		$key=I('post.searchname');
		$sql="select * from yjl_goods where yjl_name  like '%".$key."%'";
		//echo $sql;
		$data=M()->query($sql);
		$this->assign('list',$data);
		$this->display();	
	}
	public function shownew(){
		parent::mod("news","yjl_id");
	}
	public function showgood(){
		$id=I('get.id');
		//所有信息
		$sql="select * from yjl_goods where yjl_id={$id}";
		//echo $sql;exit;
		$data1=M()->query($sql);
		$this->assign("good",$data1);
		
		 //var_dump($data1); exit;
		//echo "dsd";
		//分类信息
		$sql="select * from yjl_classify where yjl_id='{$data1[0]['yjl_classid']}'";
		
		$data1=M()->query($sql);
		$this->assign("classname",$data1);
		
		//最新评论信息
		$sql="select * from yjl_messages inner join yjl_users inner join yjl_goods on yjl_users.yjl_id=yjl_messages.yjl_uid and yjl_goods.yjl_id=yjl_messages.yjl_gid
		 where yjl_messages.yjl_gid={$id}";
		$res=M()->query($sql);
		$this->assign("meslist",$res);
		$this->display();
	}
		public function add(){//添加
		$data=I('post.');
		$this->model=D("messages");
		if($this->model->create($data)){
				$this->model->add();
				$position="List/showgood/id/{$data['yjl_gid']}";
				//echo $position;
				$this->success('增加成功！',U($position));
			}
	}
}	
